package com.fs.api.enumeration;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fs.common.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import static com.fs.common.enumeration.BusinessExceptionEnum.PARAM_ERROR;

@Getter
@AllArgsConstructor
public enum ProcessResult {
    SUCCESS("是"),
    FAILURE("否");

    @EnumValue
    @JsonValue
    private final String value;

    public static ProcessResult fromValue(String value) {
        for (ProcessResult result : ProcessResult.values()) {
            if (result.getValue().equals(value)) {
                return result;
            }
        }
        throw new BusinessException(PARAM_ERROR);
    }
}
